const mongoose=require('mongoose');
const config=require('../config/config');

const AuthSchema = new mongoose.Schema({
    type:{//授权类型
        type:String,
        //enum:['code','implicit','password','client']/*目前只支持code(授权码)模式*/,
        default:'code'
    },
    client_id:String,
    scope:{//权限
        type:String,
        enum:config.auth.scopes,
        default:'read'
    },
    user:{//资源拥有者
        type:mongoose.Schema.ObjectId,
        ref:'User'
    },
    code:String,//授权码
    token:String,//令牌
    refresh_token:String,//刷新令牌
    trustful:{//是否信任
        type:Boolean,
        default:true
    },
    time:Date
});


module.exports=mongoose.model('Auth',AuthSchema);